<?php

function est_autorise($action, $type="lecture"){

        if($_SESSION['util']->profil == "1")
                return 1;

        if(isset($_SESSION['util']->autorisation[$action]) && $_SESSION['util']->autorisation[$action]->lecture)
                return 1;

        return 0;

}

/* Compatibilité < 1.5.0 */
function modules_fonction($fonc, $args = "", $nom = ""){

	$search = "";

	if($nom != "")
		$search .= "and nom='$nom'";

	$modules = new Modules();
	$query = "select * from $modules->table where actif='1' $search order by classement";
	$resul = CacheBase::getCache()->mysql_query($query, $modules->link);
	if($resul == "" || count($resul) == 0) return "";

	foreach($resul as $row) {

		$nomclass = $row->nom;
		$nomclass[0] = strtoupper($nomclass[0]);

		if(! file_exists(realpath(dirname(__FILE__)) . "/../client/plugins/" . $row->nom . "/" . $nomclass . ".class.php")){
			echo "Erreur dans le chargement du module " . $row->nom;
			exit;
		}

		include_once(realpath(dirname(__FILE__)) . "/../client/plugins/" . $row->nom . "/" . $nomclass . ".class.php");
		$tmpobj = new $nomclass();
		if(strtolower(get_parent_class($tmpobj)) != "pluginsclassiques" && strtolower(get_parent_class($tmpobj)) != "pluginspaiements" && strtolower(get_parent_class($tmpobj)) != "pluginstransports") return "";
		if(method_exists($tmpobj, $fonc))
			$tmpobj->$fonc($args);

	}
}
?>